interface PageData{
  SDKVersion?: string,
  useComponent? :boolean,
  useComponent2? :boolean,
}

interface PageMethods{
  scan():void
}

Page<PageData,PageMethods>({
  data: {
    SDKVersion: '',
  },
  onLoad(query) {
    // 页面加载
    console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
  },
  onReady() {
    // 页面加载完成
  },
  onShow() {
    // 页面显示
    this.setData({
      SDKVersion: my.SDKVersion,
    })
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
  scan(){
    my.scan({
      success: (res) => {
        my.alert({ content: '扫描成功，结果：' + JSON.stringify(res), });
      },
      fail: (error) => {
        my.alert({ content: '扫描失败，结果：' + JSON.stringify(error), });
      },
      complete: (res) => {
        my.showToast({ content: 'complete回调！', });
      },
    });
  }
});